#include <iostream>
using namespace std;

const int N=1e4+10;
int a[N],b[N],g[N],k[N];
int n=0;
int x,y;

int find()
{
	for(int i=n;i>=1;i--)
	{
		if(a[i]<=x&&b[i]<=y&&a[i]+g[i]>=x&&b[i]+k[i]>=y) return i;
	}
	return -1;
}
int main() 
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>g[i]>>k[i];
	cin>>x>>y; 
	cout<<find();
	
	return 0;
}
